// run: $exec < bfdiff.in
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <complex>
#include <cassert>
// #pragma comment(linker,"/STACK:102400000,102400000")
using namespace std;
#define LL long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
template <typename T> inline void checkMax(T &a, T b) {a = a>b?a:b;}
template <typename T> inline void checkMin(T &a, T b) {a = a<b?a:b;}
typedef pair<int, int> PII;
typedef vector<int> vi;
const double PI = acos(-1.0);
const double eps = 1e-8;
const LL INF = 1e16;
int T, D, S1, S2, Cas = 1;

int geth(int d) {
	int dep = 0;
	while (d) {
		d >>= 1;
		dep ++;
	}
	return dep;
}

LL get(int bit) {

}

void work() {
	printf("Case #%d: ", Cas ++);
	scanf("%d %d %d", &D, &S1, &S2);
	if (S1 > S2) swap(S1, S2);
	S1 = max(0, S1), S2 = min(S2, 32);
	int h = geth(D);
	LL ans = 0LL;
	for (int i = 0; i < S1 - 1; i ++) {
		ans += 1ll << i;
	}
	ans += max(1 << h, 1 << (S1 - 1));
	if (D > 0) {
		LL tmp = 0LL;
		int pnt = 0;
		for (int i = h - 1; i >= 0; i --) {
			if (D & (1 << i)) {
				tmp += (1ll << i);
				pnt ++;
			} else {
				if (pnt + 1 > S2) continue;
				if (pnt + 1 + i < S1) continue;
				int rs1 = S1 - pnt - 1, rs2 = S2 - pnt - 1;
				if (rs1 < 0) rs1 = 0;
				ans = min(ans, tmp + (1 << i) + (1 << rs1) - 1);
			}
		}
	}
	printf("%lld\n", ans);
}
int main() {
#ifdef __SKT__
	freopen("in", "r", stdin);
#endif
	scanf("%d", &T);
	while (T --) {
		work();
	}
	return 0;
}
